package com.user.write.service.impl;

import com.user.write.dao.UserMapper;
import com.user.write.dto.UserDTO;
import com.user.write.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * @ClassName UserServiceImpl
 * @Desecription TODO 1.2新增
 * @Author gjy
 * @Date 2021/3/23 15:34
 * @Version 1.2
 **/
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    public int addOne(UserDTO userDTO) {
        Date date = new Date();
        userDTO.setUpdateTime(date);
        userDTO.setUpdateUser("admin");
        int i = userMapper.addOne(userDTO);
        return i;
    }

    public void updateOne(UserDTO userDTO) {
        Date date = new Date();
        userDTO.setUpdateTime(date);
        userDTO.setUpdateUser("admin");
        userMapper.updateOne(userDTO);
    }

    public void deleteOne(int id) {
        userMapper.deleteOne(id);
    }

    public int addMany(List<UserDTO> list) {

        for (UserDTO userDTO : list) {
            Date date = new Date();
            userDTO.setUpdateTime(date);
            userDTO.setUpdateUser("admin");
            userDTO.setShcoolOrganizaId(1240);
        }

        return userMapper.addMany(list);
    }
}
